package com.lagou.ex.service;

import com.lagou.ex.dao.UserRepository;
import com.lagou.ex.entity.TbUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

@Service
@Transactional
public class UserService {
    @Autowired
    private UserRepository userRepository;

    public List<TbUser> findAll() {
        return userRepository.findAll();
    }

    public TbUser findByCondition(TbUser user) {
        List<TbUser> uList = userRepository.findByLoginnameAndLoginpass(user.getLoginname(), user.getLoginpass());
        if (null == uList || uList.size() != 1) {
            return null;
        }
        return uList.get(0);
    }

    public void updateBean(TbUser user) {
    }

    public void deleteBean(Long id) {
    }

}
